<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Visual Admin Dashboard - Preferences</title>
<meta name="description" content="">
<meta name="author" content="templatemo">
<!-- 
    Visual Admin Template
    https://templatemo.com/tm-455-visual-admin
    -->
<link
	href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,700'
	rel='stylesheet' type='text/css'>
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/templatemo-style.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
<script src="js/jquery-1.11.2.min.js"></script>
<!-- jQuery -->
<script src="js/jquery-migrate-1.2.1.min.js"></script>
<!--  jQuery Migrate Plugin -->
<!--  <script src="https://www.google.com/jsapi"></script>Google Chart -->
<script type="text/javascript" src="js/templatemo-script.js"></script>
<!-- Templatemo Script -->
<script src="js/jquery.cookie.js"></script>



</head>
<body>
	<!-- Left column -->
	<div class="templatemo-flex-row">
		<div class="templatemo-sidebar">
			<header class="templatemo-site-header">
				<div class="square"></div>
				<h1>Visual Admin</h1>
			</header>
			<div class="profile-photo-container">
				<img src="images/profile-photo.jpg" alt="Profile Photo"
					class="img-responsive">
				<div class="profile-photo-overlay"></div>
			</div>
			<!-- Search box -->
			<!--<form class="templatemo-search-form" role="search">
				<div class="input-group">
					<button type="submit" class="fa fa-search"></button>
					<input type="text" class="form-control" placeholder="Search"
						name="srch-term" id="srch-term">
				</div>
			</form>-->
			<div class="mobile-menu-icon">
				<i class="fa fa-bars"></i>
			</div>
			<nav class="templatemo-left-nav">
				<ul>
					<li><a href="index.html"><i class="fa fa-home fa-fw"></i>主页</a></li>
					<li><a href="Memorize_words.html"><i
							class="fa fa-bar-chart fa-fw"></i>背单词</a></li>
					<li><a href="Ranking.html"><i class="fa fa-database fa-fw"></i>排行榜</a></li>
					<li><a href="words.html"><i class="fa fa-map-marker fa-fw"></i>words</a></li>
					<li><a href="records.html"><i class="fa fa-users fa-fw"></i>单词记录</a></li>
					<li><a href="Test.html"><i
							class="fa 	fa fa-align-justify fa-fw"></i>单词复习</a></li>
					<li><a href="myinfo.html"><i class="fa fa-bar-chart fa-fw"></i>个人信息</a></li>

					<li><a href="setting.html" class="active"><i
							class="fa fa-sliders fa-fw"></i>设置</a></li>
					<li><a href="../login&regist.html"><i
							class="fa fa-eject fa-fw"></i>注销</a></li>
				</ul>
			</nav>
		</div>


		<div class="templatemo-content col-1 light-gray-bg">
			<div class="templatemo-content-widget white-bg">
				<h2 class="margin-bottom-10  p_size">设置</h2>
				<br />
				<form action="../set" class="templatemo-login-form" method="post" enctype="application/x-www-form-urlencoded">
					<div class="row form-group ">
						<div class="  form-group wid t_size">
							<label for="inputFirstName">每次背的个数</label> <input name="everynum"
								type="text" class="form-control " id="inputFirstName1"
								placeholder="30">
						</div>
						<div class="  form-group wid t_size">
							<label for="inputLastName">最少重复次数</label> <input name="leastnum"
								type="text" class="form-control" id="inputLastName2"
								placeholder="3">
						</div>
						<div class=" form-group wid t_size">
							<label for="inputLastName">选择的书籍</label> <input name="booktype"
								type="text" class="form-control" id="inputLastName3"
								placeholder="3">
						</div>
						<div class=" form-group wid t_size">
							<label for="inputLastName">显示单词数量</label> <input name="bookpag"
								type="text" class="form-control" id="inputLastName4"
								placeholder="30">
						</div>
					</div>





					<div class="row form-group size">

						<div class="col-lg-12 form-group ">
							<h2 class="margin-bottom-10">背单词顺序</h2>
							<div class="margin-right-15 templatemo-inline-block">
								<input type="radio" name="sequence" id="r4" value="1"> <label
									for="r4" class="font-weight-400"><span></span>顺序</label>
							</div>
							<div class="margin-right-15 templatemo-inline-block size">
								<input type="radio" name="sequence" id="r5" value="0" checked>
								<label for="r5" class="font-weight-400"><span></span>乱序</label>
							</div>
						</div>
					</div>





					<div class="row form-group size">
						<div class="col-lg-12 form-group">
							<h2 class="margin-bottom-10">是否显示翻译</h2>
							<div class="margin-right-15 templatemo-inline-block">
								<input type="radio" name="istranslate" id="r6" value="1">
								<label for="r6" class="font-weight-400"><span></span>显示</label>
							</div>
							<div class="margin-right-15 templatemo-inline-block">
								<input type="radio" name="istranslate" id="r7" value="0" checked>
								<label for="r7" class="font-weight-400"><span></span>不显示</label>
							</div>
						</div>
					</div>

					<div class="form-group text-right loc">
						<button type="submit" class="templatemo-blue-button " id="sc">Update</button>
						<button type="reset" class="templatemo-blue-button " id="gx">Reset</button>
					</div>

				</form>
			</div>
		</div>

		<!-- JS -->
		<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
		<!-- jQuery -->
		<script type="text/javascript" src="js/bootstrap-filestyle.min.js"></script>
		<!-- http://markusslima.github.io/bootstrap-filestyle/ -->
		<script type="text/javascript" src="js/templatemo-script.js"></script>
		<!-- Templatemo Script -->

		<script>
	var set;
	$.ajax({
		type:"get",
		url:"../getset",
		async:false,
		success: function(res){
			 set = JSON.parse(res);
			 console.log(set);
			 console.log(set["bookpag"]);
			 console.log(document.getElementsByName("bookpag").value);
			 
			 document.getElementsByName("bookpag")[0].value=set["bookpag"];
			 document.getElementsByName("booktype")[0].value=set["booktype"];
			 document.getElementsByName("everynum")[0].value=set["everynum"];
			 document.getElementsByName("leastnum")[0].value=set["leastnum"];
			 if(set["sequence"]==0){
			 	 document.getElementsByName("sequence")[1].checked=true;
			 }else{
			 	 document.getElementsByName("sequence")[0].checked=true;
			 }
			 if(set["istranslate"]==0){
			 	 document.getElementsByName("istranslate")[1].checked=true;
			 }else{
			 	 document.getElementsByName("istranslate")[0].checked=true;
			 }
			 
			 
		}
	});
	
//每次背的个数
$("#inputFirstName1");
//最少1重复次数
$("#inputFirstName2");
//选择的书籍
$("#inputFirstName3");
//显示单词个数
$("#inputFirstName4");
//单词顺序
$("#r4");
//单词乱序
$("#r5");
//显示翻译
$("#r6");
//不显示翻译
$("#r7");
//上传设置
$("#sc");
//更新设置
$("#gx");


$("#sc").click(function(){
	console.log("???");
	console.log(document.getElementById("inputFirstName1").innerHTML);
})

$("#gx").click(function(){
	$.ajax({
		type:"post",
		url:"../reset",
		async:true,
		success:function(){
			$.ajax({
		type:"get",
		url:"../getset",
		async:false,
		success: function(res){
			 set = JSON.parse(res);
			 console.log(set);
			 console.log(set["bookpag"]);
			 console.log(document.getElementsByName("bookpag").value);
			 
			 document.getElementsByName("bookpag")[0].value=set["bookpag"];
			 document.getElementsByName("booktype")[0].value=set["booktype"];
			 document.getElementsByName("everynum")[0].value=set["everynum"];
			 document.getElementsByName("leastnum")[0].value=set["leastnum"];
			 if(set["sequence"]==0){
			 	 document.getElementsByName("sequence")[1].checked=true;
			 }else{
			 	 document.getElementsByName("sequence")[0].checked=true;
			 }
			 if(set["istranslate"]==0){
			 	 document.getElementsByName("istranslate")[1].checked=true;
			 }else{
			 	 document.getElementsByName("istranslate")[0].checked=true;
			 }
			 
			 
		}
	});
		}
	});
})

	
</script>
</body>
</html>
